package com.ljt.yupictureddd.domain.space.valueobject;

import cn.hutool.core.util.ObjUtil;
import lombok.Getter;

import java.util.Arrays;

@Getter
public enum SpaceLevelEnums {

    COMMON("普通版", 0, 100, 100L * 1024 * 1024),

    PROFESSIONAL("专业版", 1, 1000, 1000L * 1024 * 1024),

    FLAGUSHIP("旗舰版", 2, 10000, 1000L * 1024 * 1024);


    private final String text;

    private final int value;

    private final long maxCount;

    private final long maxSize;

    SpaceLevelEnums(String text, int value, int maxCount, long maxSize) {
        this.text = text;
        this.value = value;
        this.maxCount = maxCount;
        this.maxSize = maxSize;
    }

    /**
     * 根据value获取枚举
     *
     * @param value
     * @return
     */
    public static SpaceLevelEnums getEnumByValue(int value) {
        if (ObjUtil.isEmpty(value)) {
            return null;
        }
        SpaceLevelEnums userRoleEnums = Arrays.stream(SpaceLevelEnums.values())
                .filter(space -> space.getValue() == value)
                .findFirst()
                .get();
        return userRoleEnums;
    }
}
